import { type UserConfig, type ConfigEnv, defineConfig } from "vite"
import viteBaseConfig from "./vite.base.config"
import viteDevConfig from "./vite.dev.config"
import viteProConfig from "./vite.pro.config"

const envConfig = {
  build: (mode: string) => {
    return { ...viteBaseConfig(mode), ...viteProConfig(mode) }
  },
  serve: (mode: string) => {
    return { ...viteBaseConfig(mode), ...viteDevConfig(mode) }
  }
}

export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => envConfig[command](mode))
